#pragma once

#include <QMutex>
#include <QMutexLocker>
#include <QDebug>
#include <QHash>
#include "rviz_custom_plugins/utils/interactive_marker_thread.h"

namespace rviz_custom_plugins
{

namespace utils
{

class InteractiveMarkerManager: public QObject
{
    Q_OBJECT

public:

    // 获取单例实例（线程安全）
    static InteractiveMarkerManager* getInstance();

    std::shared_ptr<InteractiveMarkerThread> addThread(QString& taskName);

    std::shared_ptr<InteractiveMarkerThread> getRunningThread(QString& taskName);

private:
    InteractiveMarkerManager() = default;
    InteractiveMarkerManager(const InteractiveMarkerManager&) = delete;
    InteractiveMarkerManager& operator=(const InteractiveMarkerManager&) = delete;

    static InteractiveMarkerManager* instance;
    static QMutex mutex;


    QHash<QString, std::shared_ptr<InteractiveMarkerThread>> taskMap;
};


}

}
